#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string.h>

class string
{
public:

	string(const char* str = "")
		:_size(strlen(str)),
		_str(nullptr)
	{
		_capacity = _size + 1;
		_str = new char[_capacity];
		strcpy(_str, str);
	}
	void swap(string& a)
	{
		std::swap(a._capacity, this->_capacity);
		std::swap(a._size, this->_size);
		std::swap(a._str, this->_str);
	}
	string(const string& s)
		:_str(nullptr)
	{
		string tmp(s._str);
		swap(tmp);
	}

	string& operator=(const string& s)
	{
		string tmp(s._str);
		swap(tmp);
		return *this;
	}

	~string()
	{
		delete[] _str;
		_size = _capacity = 0;
	}

private:
	size_t _size = 0;
	size_t _capacity = 0;
	char* _str;

};



int main()
{
	string s1("hello world");
	string s2(s1);
	string s3 = s2;

	return 0;
}